import 'package:flutter/material.dart';
import 'package:wy/utils/screen_util.dart';

class Header extends StatelessWidget {
  final String title;
  final bool isHero; //为了解决两个hero不能重叠使用
  final Widget right;

  Header({Key key, this.title, this.isHero, this.right}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final screen = Screen(context);
    final child = Container(
      height: screen.calc(88),
      child: Row(
        children: [
          Container(
            alignment: Alignment.centerLeft,
            width: screen.calc(100),
            child: GestureDetector(
              onTap: () {
                Navigator.pop(context);
              },
              child: Icon(Icons.arrow_back),
            ),
          ),
          Expanded(
              child: Center(
                  child: Text(title,
                      style: TextStyle(
                        fontSize: screen.calc(34),
                        fontWeight: FontWeight.w700,
                      )))),
          Container(
            alignment: Alignment.centerRight,
            // width: screen.calc(100),
            // child: Icon(Icons.share),
            child: right != null ? right : Container(),
          ),
        ],
      ),
    );
    if (isHero) {
      return Hero(
        tag: '_login_page_header',
        child: child,
      );
    } else {
      return child;
    }
  }
}
